﻿//*********************************************************************
//
//  文件名：MenuController
//
//  作者： LW
//
//  作用：
//
//  日期：2015/9/18 10:35:29
//
//*********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using Framework.Common;
using YouTravel.DomainService;
using YouTravel.DomainModels;

namespace Application.WebAPI.Controllers
{
    /// <summary>
    /// MenuController
    /// 菜单
    /// </summary>
    [RoutePrefix("api/menu")]
    public class MenuController : BaseController
    {
        IMenuService menuService;
        DataResult dataResult = new DataResult() { Code = ResponseStatusCode.Error, Msg = "" };

        public MenuController(IMenuService _menuService)
        {
            this.menuService = _menuService;
        }

        /// <summary>
        /// 获取当前用户的权限
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("usermenu")]
        public DataResult GetUserMenu()
        {
            List<Menu> menu = this.menuService.GetUserMenu(LoginUser.ID);
            dataResult.Code = ResponseStatusCode.Success;
            dataResult.Data = menu.Select(c => c.Code).ToList();
            return dataResult;
        }
    }
}